package com.brainydroid.framework;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

/*
 * AndroidGraphics.java
 * added public void drawPixmap(Pixmap pixmap, int x, int y, int w, int h)
 * 
 * 
 * 
 */

/**
 * The graphic manager manages the display of all objects of the experiments
 * by calling their method draw when they are visible
 * @author vincent
 *
 */
public class GraphicManager {
	
	Scene scene_;
	    
    float scalex_;
    float scaley_;
    
    
	public ArrayList<Object> objects_; // array of objects where objects are sorted by display order
	
	/**
	 * Constructor
	 * @param s
	 */
	public GraphicManager(Scene s) {
		
        scalex_ = (float)Gdx.graphics.getWidth() / 800f;
        scaley_ = (float)Gdx.graphics.getHeight() / 480f;
		
		scene_ = s;
		objects_ = null;
	}
		
	/**
	 * Initialize the manager by pointing to the objects declared in the Scene
	 */
	public void init() {
		objects_ = null;
		objects_ = new ArrayList<Object>(scene_.objects_.size());
		for(Object o: scene_.objects_) objects_.add(o);
	}
	

	/**
	 * Draws all objects on screen
	 * @param t
	 * @param batch
	 */
	public void drawObjects(float t,SpriteBatch batch) {
		for (Object o : objects_) {
            if (o.visible_) { o.draw(batch, scalex_, scaley_); }
		}	
	}
	
	/**
	 * Adds an object to the vector of object of the manager
	 * (These objects points to objects of the scene)
	 * @param o
	 */
	public void addObject(Object o) {
		objects_.add(o);
	}
	
	
	
}
